import requests
from requests.packages import urllib3
from lxml import etree
# from selenium import webdriver
# from time import sleep
# from bs4 import BeautifulSoup
# from selenium.webdriver.chrome.options import Options
# import os

# 《金田一少年之事件簿》漫画网址
# url = "https://www.manhuagui.com/comic/4756/"
# 第27卷
url = "https://www.manhuagui.com/comic/4756/43462.html"
# 第27卷第1页URL
# url = "https://us.hamreus.com/ps1/j/jty/27/000.png.webp?e=1596359485&m=pr6flKXgcjW4hJtggv74pQ"

# 设置HTTP请求头
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
    'referer': 'https://www.manhuagui.com/comic/4756/',
    # 'host': 'https://www.manhuagui.com',
    'cookie': '_ga=GA1.2.334453631.1571501679; country=CN; _gid=GA1.2.522077123.1597587035'
    }

# 给网页发送请求
# data = requests.get(url).text
urllib3.disable_warnings()
data = requests.get(url, headers, verify=False)
# 打印HTTP响应数据
# print(data.status_code)
print(data.text)

# 将网页信息转换成xpath可识别的类型
html = etree.HTML(data.text)
# print(html)

# // 提取某个标签的所有信息
# @ 选取属性
# / 选择某一个标签
img_url = html.xpath('//div[@class="clearfix"]//div[@id="mangaBox"]//img/@src')
# print(img_url)
